package com.blb.friendsO.utils;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * IOC容器工具
 */
@ComponentScan(basePackages = "com.blb.friendsO")
@Configuration
public class ApplicationContextUtil {

    private static ApplicationContext applicationContext;

    static{
        applicationContext = new AnnotationConfigApplicationContext(ApplicationContextUtil.class);
    }

    public static Object getBean(Class clazz){
        return applicationContext.getBean(clazz);
    }
}
